package pers.goetboy.common.vaild;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;

@Target({FIELD, METHOD, TYPE, PARAMETER, ANNOTATION_TYPE, TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = DateTimeCompValidator.class)
public @interface DateTimeComp {
    String message() default "与预定日期校验不符合预期规则";

    /**
     * 比较的时间
     *
     * @return
     */
    String dateTime();


    CheckTimeInterval.Exp exp() default CheckTimeInterval.Exp.LESS;


    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * 比较方式
     */
    public enum Exp {
        /**
         * t1>t2
         * t1.isAfter(t2)
         */
        GREATER,
        /**
         * t1>=t2
         * t1.isAfter(t2) || t1.isEqual(t2)
         */
        GREATER_OR_EQUAL,
        /**
         * t1<=t2
         * t1.isBefore(t2) || t1.isEqual(t2)
         */
        LESS_OR_EQUAL,
        /**
         * t1<t2
         * t1.isBefore(t2)
         */
        LESS
    }
}
